// 必填
export const required = (message:string) => ({ required: true, message, trigger: 'blur' });
// 长度
export const length = (minLength:number, maxLength:number, label='') => (
    { minLength, maxLength, message: `${label}长度在 ${minLength} 到 ${maxLength} 个字符`, trigger: 'blur' }
)
// 手机
export const mobile = (
    { match: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
)
// 身份证号
export const identityCard = [
    required('请输入身份证号'),
    { match: /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/, message: '请输入正确的身份证号', trigger: 'blur' }
]
// 验证码
export const code = (length:number,name='验证码') => (
    { match: new RegExp(`^[0-9]{${length}}$`), message: `请输入${length}位数字${name}`, trigger: 'blur' }
)
// 信用代码
export const creditCode = [
    required('请输入社会信用代码'),
    { match: /^([0-9A-Za-z]{18})$/, message: '请输入正确的社会信用代码', trigger: 'blur' }
]


